package com.title5;

import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Iterator;

/**
 * @Author milian
 * @Date 2021/8/10 0010 20:46
 */
public class title5 {
    public static void main(String[] args) throws Exception {
        ArrayList<String> list = new ArrayList<>();
        list.add("张三");
        list.add("张二");
        list.add("张一");
        Class Clazz = Class.forName("java.util.ArrayList");
//        Method add = Clazz.getMethod("add", int.class, Object.class);
//        add.invoke(list,list.size(), 23);
//        String s = list.get(3);
//        int i = Integer.parseInt(list.get(3));
//        System.out.println(i);
        Method add = Clazz.getMethod("add", Object.class);
        Object invoke = add.invoke(list, 23);
//        System.out.println(list.get(3));
        System.out.println(list);
        Iterator<String> iterator = list.iterator();
        while (iterator.hasNext()){
            System.out.println(iterator.next());
        }
    }
}
